package com.request; /**
 * @author wzm
 * @create 2023-04-25 15:38
 */

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/request04")
public class Request04 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      //调用doPost处理
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String money = request.getParameter("money");
        System.out.println("能不能获取到上一个资源的request里的值"+money);

        //获取请求参数（查看小票）
        Object xiaopiao = request.getAttribute("xiaopiao");
        System.out.println("点餐小票为：" + xiaopiao);

        System.out.println("开始煮米线");


        //测试转发到别的资源
        //request.getRequestDispatcher("http://www.baidu.com").forward(request,response);//不可以

        request.getRequestDispatcher("/index.jsp").forward(request,response);//webapp下 可以
        request.getRequestDispatcher("/WEB-INF/index.jsp").forward(request,response);//转发可以访问web-inf


    }
}
